home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / mac / Sample Code / QuickTime / QuickTimeIntro / Play Movie w⁄Controller / Start Code / Events.c < prev    next >
Encoding:
Text File  |  2000-10-06  |  2.1 KB  |  94 lines  |  [TEXT/CWIE]

  1. // Play Movie with Controller Sample
  2. // Based on QTShell
  3. // WWDC 2000
  4.  
  5. #include "ComApplication.h"
  6. #include "ComFramework.h"
  7. #include "MacFramework.h"
  8.  
  9. //////////
  10. //
  11. // ActivateController
  12. // Activate or deactivate the movie controller in the specified window.
  13. //
  14. //////////
  15.  
  16. void ActivateController (WindowReference theWindow, Boolean IsActive)
  17. {
  18.     WindowObject         myWindowObject = NULL;
  19.     MovieController        myMC = NULL;
  20.     GrafPtr                mySavedPort = NULL;
  21.     
  22.     if (theWindow == NULL)
  23.         return;
  24.     
  25.     GetPort(&mySavedPort);
  26.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  27.     
  28.     // get the window object associated with the specified window
  29.     myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  30.     if (myWindowObject != NULL) {
  31.         myMC = (**myWindowObject).fController;
  32.         if (myMC != NULL)
  33. // Step 1. Insert MCActivate.clp here...
  34.  
  35.     }
  36.     
  37.     MacSetPort(mySavedPort);
  38. }
  39.  
  40. //////////
  41. //
  42. // Draw
  43. // Update the specified window.
  44. //
  45. //////////
  46.  
  47. void Draw (WindowReference theWindow, Rect *theRefreshArea)
  48. {
  49. #pragma unused(theRefreshArea)
  50.  
  51.     GrafPtr             mySavedPort;
  52.     
  53.     GetPort(&mySavedPort);
  54.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  55.     
  56.     BeginUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  57.     //EraseRect(theRefreshArea);        // this is important only for non-rectangular movies
  58.     
  59.     // ***insert application-specific drawing here***
  60.     
  61.     // draw the movie controller and its movie
  62. // Step 2. Insert MCActivate.clp here...
  63.     
  64.     EndUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  65.     MacSetPort(mySavedPort);
  66. }
  67.  
  68. //////////
  69. //
  70. // CheckMovieControllers
  71. // Let all movie controllers have a chance to process the event.
  72. //
  73. // Returns true if the event was handled by some movie controller, false otherwise
  74. //
  75. //////////
  76.  
  77. Boolean CheckMovieControllers (EventRecord *theEvent)
  78. {    
  79.     WindowPtr                myWindow = NULL;
  80.     MovieController            myMC = NULL;
  81.     
  82.     myWindow = QTFrame_GetFrontMovieWindow();
  83.     while (myWindow != NULL) {
  84.         myMC = QTFrame_GetMCFromWindow(myWindow);
  85.         if (myMC != NULL)
  86. // Step 3. Insert MCIsPlayerEvent.clp here...
  87.  
  88.                 return(true);
  89.         
  90.         myWindow = QTFrame_GetNextMovieWindow(myWindow);
  91.     }
  92.     
  93.     return(false);
  94. }